home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Pour scroll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  2.6 KB  |  87 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define        ScrollSize    10        /* = how much up to scroll each strip */
  15. #define        BoxSize        5        /* = width of each strip */
  16. #define        NumStrips    100        /* = MAIN_WINDOW_WIDTH/BoxSize */
  17. #define CorrectTime 2
  18.  
  19. void PourScroll(GrafPtr);
  20.  
  21. /* Scroll down in tiny strips, starting at the left and moving right.  Scroll
  22.    strips 1-(N), then strips 1-(N+1), etc.  When strip 1 is done, don't do it
  23.    anymore!  (Duh, but this was difficult to get right.)  So only scroll strips
  24.    2-(N), and so on. */
  25.    
  26. void PourScroll(GrafPtr sourceGrafPtr)
  27. {
  28.     Rect        theRect[NumStrips], dest[NumStrips];
  29.     Rect        scrollsource, scrolldest;
  30.     int            i;
  31.     int            startstrip,endstrip;
  32.     
  33.     scrollsource=gMainWindow->portRect;
  34.     scrollsource.bottom-=ScrollSize;
  35.     scrollsource.left=0;
  36.     scrollsource.right=BoxSize;
  37.     scrolldest = scrollsource;
  38.     OffsetRect(&scrolldest, 0, ScrollSize);
  39.         
  40.     for (i=0; i<NumStrips; i++)
  41.     {
  42.         dest[i] = gMainWindow->portRect;
  43.         dest[i].bottom=ScrollSize;
  44.         dest[i].left=i*BoxSize;
  45.         dest[i].right=dest[i].left+BoxSize;
  46.         
  47.         theRect[i].top=MAIN_WINDOW_HEIGHT-ScrollSize;
  48.         theRect[i].bottom=MAIN_WINDOW_HEIGHT;
  49.         theRect[i].left=i*BoxSize;
  50.         theRect[i].right=theRect[i].left+BoxSize;
  51.     }
  52.     
  53.     startstrip=0;
  54.     endstrip=1;
  55.     do
  56.     {
  57.         StartTiming();
  58.         
  59.         CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
  60.                 &scrollsource, &scrolldest, 0, 0L);
  61.         
  62.         for (i=startstrip; i<endstrip; i++)
  63.         {
  64.             CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  65.                     &theRect[i], &dest[i], 0, 0L);
  66.             theRect[i].bottom-=ScrollSize;
  67.             theRect[i].top-=ScrollSize;
  68.         }
  69.         
  70.         if (endstrip<NumStrips)
  71.         {
  72.             endstrip++;
  73.             scrollsource.right+=BoxSize;
  74.             scrolldest.right+=BoxSize;
  75.         }
  76.         if (theRect[startstrip].bottom==0)
  77.         {
  78.             startstrip++;
  79.             scrollsource.left+=BoxSize;
  80.             scrolldest.left+=BoxSize;
  81.         }
  82.         
  83.         TimeCorrection(CorrectTime);
  84.     }
  85.     while (startstrip<endstrip);
  86. }
  87.